#include<iostream>
#include<vector>
using namespace std;
long long v[100000][3];
int l;
int fun(int b,int e){
    int day=0,m=v[b][0];
    if(b<e){
        for(int i=b;i<e;i++){
            if(m<=v[i][0]&&v[i][0]+l>v[i+1][0]){
                day++;
                m=v[i][0]+l;
            }else if(m<v[i][0]&&v[i][0]+l<v[i+1][0]){
                day+=2;
                m=v[i+1][0]+l;
            }
            v[i][1]=day;
            cout<<"i="<<i<<"\tm="<<m<<"\tday="<<day<<"\tv[i][1]="<<v[i][1]<<endl;
        }
    }else{
        for(int i=b;i>e;i--){
            if(m>=v[i][0]&&v[i][0]-l<v[i-1][0]){
                m=v[i][0]-l;
                day++;
            }else if(m>v[i][0]&&v[i][0]-l>v[i-1][0]){
                day+=2;
                m=v[i-1][0]-l;
            }
            v[i][2]=day;
            cout<<"i="<<i<<"\tm="<<m<<"\tday="<<day<<"\tv[i][2]="<<v[i][2]<<endl;
        }
    }
    return day/l;
}
int main(){
    int n,k,q,a,b,c=0;cin>>n;
    for(int i=0;i<n;i++){
        cin>>v[i][0];
    }cin>>l>>q;
    fun(0,n-1);
    cout<<endl;
    fun(n-1,0);
    for(int i=0;i<q;i++){
        cin>>a>>b;
        if(a>b)cout<<v[a][2]-v[b][2]+1<<endl;
        else cout<<v[b][1]-v[a][1]+1<<endl;
    }
    return 0;
}
